<?php

/**
 * This is the model class for table "seo".
 *
 * The followings are the available columns in table 'seo':
 * @property string $id
 * @property string $category
 * @property string $record_url
 * @property string $title
 * @property string $keyword
 * @property string $description
 * @property string $tagged
 * @property integer $status
 */
class Seo extends SeoPeer
{
	var $className = __CLASS__;
	/**
	 * Returns the static model of the specified AR class.
	 * @return Seo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('category, record_url', 'required'),
			array('status', 'numerical', 'integerOnly'=>true),
			array('category', 'length', 'max'=>20),
			array('record_url, title, keyword, description', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, category, record_url, title, keyword, description, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);

		$criteria->compare('category',$this->category,true);

		$criteria->compare('record_url',$this->record_url,true);

		$criteria->compare('title',$this->title,true);

		$criteria->compare('keyword',$this->keyword,true);

		$criteria->compare('description',$this->description,true);

		$criteria->compare('status',$this->status);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
    // load seo info
    public static function load_seo_info($category = 0,$record_url = null){
        $model = Seo::model ()->find('category='.$category.' AND record_url='.$record_url);
        if(!$model) $model = new Seo ();
        return $model;
    }
}